package com.jc.service.jg.mq;

import java.util.concurrent.LinkedBlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jc.framework.util.SpringUtils;
import com.jc.service.jg.JgService;
import com.jc.service.jg.JgServiceImpl;
import com.jc.service.model.jg.GoodsSendVo;

/***
 * 
* @version:
* @Description:
* @author: Administrator
*   2018年11月27日
 */
public class Consumer extends Thread {
	private static JgService			jgService	= SpringUtils.getBean(JgService.class);
	
	Logger log = LoggerFactory.getLogger(Consumer.class);
	public LinkedBlockingQueue<GoodsSendVo> queue;
	
	public Consumer(LinkedBlockingQueue<GoodsSendVo> queue){
		this.queue = queue;
	}
	
	public void run(){
		while(true){
			try {
				GoodsSendVo goods = queue.take();
				if(goods == null) {
					log.error("从队列里面取出的goods为空");
				}
				jgService.saveGoodsPicture(goods);
				Thread.sleep(300);
			} catch (Exception e) {
				log.error("产品接收队列消费出现在错误, {},{}" , e.getMessage(),e);
			}
		
		}
	}
	
	

}
